package com.bmf.module.rbac.controller;


import com.bmf.module.rbac.service.RbacMenuService;
import com.bmf.module.rbac.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import com.bmf.core.result.R;

/**
 * (RbacMenu)表控制层
 *
 * @author makejava
 * @since 2022-12-27 15:33:18
 */
@RestController
@RequestMapping("rbacMenu")
@Api(tags = {"菜单接口"})
public class RbacMenuController{
    /**
     * 服务对象
     */
    @Autowired
    private RbacMenuService rbacMenuService;

    /**
     * 查询用户所有菜单
     */
    @GetMapping("/selectUserAll")
    @ApiOperation(value = "查询用户所有菜单")
    public R<List<RbacMenuResultVo>> selectUserAll() {
        return R.success(rbacMenuService.selectUserAll());
    }

    /**
     * 查询所有菜单
     */
    @GetMapping("/selectAll")
    @ApiOperation(value = "查询所有菜单")
    public R<List<RbacMenuResultVo>> selectAll() {
        return R.success(rbacMenuService.selectAll());
    }

    /**
     * 新增数据
     *
     * @param rbacMenuCreateVo 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增数据")
    public R<Integer> insert(@RequestBody RbacMenuCreateVo rbacMenuCreateVo) {
        return R.success(rbacMenuService.insert(rbacMenuCreateVo));
    }

    /**
     * 修改数据
     *
     * @param rbacMenuUpdateVo 实体对象
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改数据")
    public R<Void> update(@RequestBody RbacMenuUpdateVo rbacMenuUpdateVo) {
        rbacMenuService.update(rbacMenuUpdateVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除数据")
    public R<Void> delete(@RequestBody List<Integer> ids) {
        rbacMenuService.delete(ids);
        return R.ok();
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation(value = "根据id查询")
    public R<RbacMenuResultVo> selectOne(@PathVariable Serializable id) {
        return R.success(rbacMenuService.selectOne(id));
    }

}

